<template>
  <div class="cdvertising" v-for="item of data.result" :key="item.id">
    <img :src="item.imgUrl" :alt="item.linkUrl" @click="toPage(item.linkUrl)" />
  </div>
</template>

<script setup>
import img from "../../assets/home/baidu.png";
import { onMounted, reactive } from "vue";
import { getApiAdTop } from "@/api/api";
const data = reactive({result:{ imgUrl: img, linkUrl: "http://www.baidu.com" }});
const toPage = (url) => {
  window.open(url);
};
onMounted(() => {
  getAdTop()
})
const getAdTop = () => {
  getApiAdTop().then(res => {
    data.result = res
  })
}
</script>

<style lang="less" scoped>
.cdvertising img {
  width: 100%;
  vertical-align: middle;
}
</style>
